#ifndef _VULCAN_
#define _VULCAN_

#include "aerial\Weapon.h"

#include "hge\hge.h"
#include "hge\hgeparticle.h"
#include "hge\hgeresource.h"

class FlyObject;

class VulcanRayCastCallback;

class Vulcan: public Weapon
{
	enum VulcanState { Expanding, Full, Fade };
public:
	static bool available(FlyObject*);
	Vulcan(float x0, float x1, float vx, float vy, FlyObject*);
	~Vulcan();

	bool isOn();
	void stop();

	void render();
	bool update(float dt);

	void Hit(float fraction);

	inline virtual uchar GetWeaponType() { return TYPE_WEAPON_VULCAN; }
private:
	b2Vec2 destPoint;
	float t_range, max_range;
	hgeSprite	*sprInner, *sprOuter;
	hgeParticleSystem *psInner, *psOuter;

	VulcanState vulcanState;
	float powerConsume;
	/// @brief speed in which Vulcan is shoot out
	static const float Speed;
	/// @brief speed in which Vulcan is shoot in box2d
	static const float BSpeed;
	static const float MinPowerRequire;
	VulcanRayCastCallback* VRCC ;

	/// @brief power consumed per seconed
	static const float PCPS;
	static const int FadeSpeed;
	static const float MaxRange;
};

class VulcanRayCastCallback: public b2RayCastCallback
{
public:
	VulcanRayCastCallback(Vulcan* _vulcan): vulcan(_vulcan)  {	m_fixture = 0;	}

	float32 ReportFixture(b2Fixture *fixture,  const b2Vec2& point,  const b2Vec2& normal, float32 fraction);
private:
	b2Fixture* m_fixture;
	b2Vec2 m_point;
	b2Vec2 m_normal;
	float32 m_fraction;
	Vulcan* vulcan;
};



#endif